<?php echo Modules::run('content/header_content') ?>
 
  <div class="container main">
    <div>
      
      
      <div class="15">
        <div class="row">
          <div class="span15 content">
  				<h1>Order History</h1>  
          </div>
        </div>
        <div class="row">
        <?php $user_id = Modules::run('auth/get_user_id');
		
			  $cus = $this->order_model->get_customer_by_user($user_id); ?>
          
          <div class="span15 content">
            <div class="row box-product-row box">
              <div class="just list" id="orderHistory">
              
		      <?php $currency = $this->currency->getCurrency();?>
              <?php if(count($order) > 0){ ?>
              <?php foreach ($order as $key => $val) { ?>

				<?php 
				
                $order_id = $val->order_id;
				$order_cid = $val->order_cid;
                //$price = number_format($val->price,2,',','.'); 
        		$price = $this->currency->format($val->total, $currency);
                
                ?>
              
                <div class="box-product-list mix" style="display:inline-block; opacity:1;">
                  <div class="row">
                  	<div class="span6 orderCode" >
                    	<b>Order Code : </b> <?php echo $order_cid; ?> &nbsp;&nbsp;
                        <a href="<?php echo site_url('account/order_info/'.$order_cid);?>" title = "View"><i class="icon-list-alt"></i></a>
                    </div>
                    <div class="span4">
                    	<b>Date Added :</b> <?php echo $val->date_added; ?> <br />
                        <b>Products : </b>
                        <?php $count = $this->order_model->count_product_by_cid($cus->customer_id, $order_cid); ?>
                    	<?php foreach($count as $cou){ ?>
                    		<?php echo $cou->count_product;?> 
                    	<?php } ?>
                    </div>
                    <div class="span4">
                    	<b>Customer : </b><?php echo $val->	firstname; ?> <?php echo $val->	lastname; ?><br />
                        <b>Total : </b>
                        <?php $total = $this->order_model->sum_total_by_cid($cus->customer_id, $order_cid); ?>
                    	<?php foreach($total as $tot){ ?>
                    		<?php echo $this->currency->format($tot->total, $currency)?> 
                    	<?php } ?>
                    </div>
                  </div>
                </div>
                <hr />
				<?php } ?>
                <?php }else{  ?>
                	<div class="span6">
						<b>Your order history is empty.</b>
                    </div>
				<?php }?>
              </div>
			  
              <div class="clearfix">
            </div>
             <div class="storefront-bottom">
                <div id="paging_area" class="">
                    <center>
                      <?php echo $pagination; ?>
                    </center>
                </div>
                <!--<div class="storefront-show">
                </div>-->
              </div>
              <div class="order-back">
              	<a href="<?php echo site_url('account'); ?>" class="btn" id="cancel" type="button" name="back" value="Back">Back</a>
              </div>
          </div>
          
        </div>
      </div>
    </div>
  </div>
</div>



<?php echo Modules::run('content/footer_content') ?>